﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace The_LarX
{
    public class QueuedActionManager
    {
        private Dictionary<int, Action> startDrawQueuedParts = new Dictionary<int, Action>();
        private Dictionary<int, Action> drawQueuedParts = new Dictionary<int, Action>();

        public Dictionary<int, Action> StartDrawQueuedAction
        {
            get { return startDrawQueuedParts; }
        }
        public Dictionary<int, Action> DrawQueuedActions
        {
            get { return drawQueuedParts; }
        }

        public int BiggestStartQueued;
        public int BiggestQueued;

        public void AddQueuedAction(int key, Action act)
        {
            while (drawQueuedParts.ContainsKey(key))
                key++;
            if (key > BiggestQueued)
                BiggestQueued = key;
            drawQueuedParts.Add(key, act);
        }
        public void AddQueuedActionAtEnd(Action act)
        {
            int key = BiggestQueued++;
            AddQueuedAction(key, act);
        }

        public void AddStartQueuedAction(int key, Action act)
        {
            while (startDrawQueuedParts.ContainsKey(key))
                key++;
            if (key > BiggestStartQueued)
                BiggestStartQueued = key;
            startDrawQueuedParts.Add(key, act);
        }
        public void AddStartQueuedActionAtEnd(Action act)
        {
            int key = BiggestStartQueued++;
            AddStartQueuedAction(key, act);
        }
    }
}
